<?php
/**
 * Created by PhpStorm.
 * User: jocky
 * Date: 2017/7/20
 * Time: 下午1:07
 */
$realNameStr = '';
if ($level==1) {
    $userID=$userInfo->userID;
    $userTime=$userInfo->RegisterDate;
    $userpsw=$userInfo->loginpsw;
}else
{
    $userID=$userInfo->id;
    $userTime=$userInfo->addDate;
    $userpsw=$userInfo->loginPsw;
}
$levelInfo['is_first']=1;
foreach ($realNameInfo as $v) {
    if ($v['is_must']) {
        $v['key'] = ' * ' . $v['key'];
    }
    $realNameStr .= <<<EOF
<div class='form-group'>
    <label class="control-label col-md-3 col-sm-3 col-xs-12">{$v["key"]}</label>
    <div class="col-md-7 col-sm-7 col-xs-12">
EOF;

    switch ($v['type']) {
        case 1://填空
            $realNameStr .= "<input type='text' name={$v['id']} class='form-control' value='" . $v['field_value'] . "'>";
            break;
        case 3://单选
        case 7://选择框
            $fieldTemplates = explode('|', $v['val']);//字段模板
            $selected = $v['field_value'] ? $v['field_value'] : 0;

            foreach ($fieldTemplates as $value) {
                $tmp = explode('=>', $value);
                if ($selected == $tmp[0]) {
                    $realNameStr .= "<input type='text' d class='form-control' value='" . $tmp[1] . "'>";
                }
            }
            break;
        case 5://图片
            $imgs_id="imgs_".$v['id'];
            $uid_s=$v['id'];
            $realNameStr .= "<img src='" . $v['field_value'] . "' class='img-responsive img-thumbnail' id='$imgs_id'/>
            <div class='input-group'>
            <input class='form-control' type='file' oninput='upimg(this,$imgs_id)' />
            <span class='input-group-btn'>
            <button type='button' class='btn btn-primary btn-block' onclick='realNameCheckObj.imgmodify($userID,$uid_s)'>更 改</button>
            </span></div>
            ";
            break;
        default:
            break;
    }
    $realNameStr .= "</div></div>";
}
?>

<div class="row">
    <div class="col-md-12 col-sm-12 col-xs-12">
        <ul class="nav nav-tabs bar_tabs" role="tablist">
         <li role="presentation" class="active">
                <a href="#trade_info_content1" role="tab" data-toggle="tab"
                   aria-expanded="true">
                    客户信息
                </a>
         </li>

            <?php if ($levelInfo['is_first']) { ?>
                <li role="presentation">
                    <a href="#trade_info_content5" role="tab" data-toggle="tab"
                       aria-expanded="true">
                        实名信息
                    </a>
                </li>
            <?php } ?>
        </ul>
        <div class="tab-content" style="margin-top:30px;">

            <div class="tab-pane fade active in" id="trade_info_content1">
                <form class="form-horizontal form-label-left" style="max-height: 500px;overflow-y: scroll;" id="form_realNameAuth">
                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">编号</label>
                        <div class="col-md-7 col-sm-7 col-xs-12">
                            <div class="form-control"><?= $userID; ?></div>
                        </div>
                    </div>
<!--                     <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">姓名</label>
                        <div class="col-md-7 col-sm-7 col-xs-12">
                            <div class="form-control"><?= $userInfo->accountName; ?></div>
                        </div>
                    </div> -->
                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">姓名</label>
                        <div class="col-md-7 col-sm-7 col-xs-12">
                            <div class="input-group">
                                <input type="text" min="1" class="form-control"
                                name="alias"
                                placeholder="请输入正确的姓名信息！"
                                value="<?= $userInfo->accountName; ?>"/>

                                <span class="input-group-btn">
                                    <button type="button" class="btn btn-primary btn-block"
                                    onclick="traderObj.changeAlias(<?= $userID ?>,this)">
                                    更 改
                                </button>
                            </span>
                        </div>
                    </div>
                </div>
                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">
                            注册日期
                        </label>
                        <div class="col-md-7 col-sm-7 col-xs-12">
                            <div class="form-control"><?=$userTime; ?></div>
                        </div>
                    </div>
                        <div class="form-group">
                            <label class="control-label col-md-3 col-sm-3 col-xs-12">密码</label>
                            <div class="col-md-7 col-sm-7 col-xs-12">
                                <div class="input-group">
                                <input type="text" min="1" class="form-control"
                                       name="pwd"
                                       placeholder="密码长度为6-12位"
                                       value="<?= $userpsw; ?>"/>

                                <span class="input-group-btn">
                                    <button type="button" class="btn btn-primary btn-block"
                                            onclick="traderObj.modifyPwd1(<?= $userID ?>,this)">
                                        更 改
                                    </button>
                                </span>
                            </div>
                            </div>
                        </div>
                </form>
            </div>

            <?php
            if ($levelInfo['is_first']) { ?>
                <div class="tab-pane fade" id="trade_info_content5">
                    <?php if ($realNameStr) { ?>
                        <form class="form-horizontal form-label-left" style="max-height: 480px;overflow-y: scroll;" >
                            <?= $realNameStr; ?>
                <div class="form-group">
                <label class="control-label col-md-3 col-sm-3 col-xs-12">拒绝原因：</label>
                <div class="col-md-7 col-sm-7 col-xs-12">
                    <textarea class="form-control"
                              rows="3"
                              disabled="true"
                              id="realNameCheckErrorMsg"
                              placeholder="执行拒绝操作时为必填项，客户端会显示拒绝的原因">当前信息提交之后发现问题,管理员建议用户重新提交</textarea>
                </div>
            </div>
                         <span class="input-group-btn">
                          <button type="button" class="btn btn-primary btn-block"
                           onclick="realNameCheckObj.operate(<?= $userID ?>,1)">
                                        确认修改
                                    </button>
                                </span>
                        </form>
                    <?php } else { ?>
                        <table class="table table-bordered table-striped">
                            <tbody>
                            <tr>
                                <td style="text-align: center;">暂无实名信息</td>
                            </tr>
                            </tbody>
                        </table>
                    <?php } ?>
                </div>
            <?php } ?>
        </div>
    </div>
</div>
<script>
    function upimg(files,imgs_id) {
        var imgs=document.getElementById(imgs_id.id);
        if (files.files && files.files[0]) {
            var reader = new FileReader();
            reader.onload = function(evt) {
                imgs.src=evt.target.result;
            }
            reader.readAsDataURL(files.files[0]);
        } else {
            // console.log(files.value);
            alert("图片资源过大或者有问题，请联系管理员！");
        }
    }
</script>